package com.love.marriage.defaultAmountConfigRecord.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.love.marriage.common.vo.Result;
import com.love.marriage.defaultAmountConfigRecord.service.DefaultAmountConfigRecordService;
import com.love.marriage.defaultAmountConfigRecord.vo.DefaultAmountConfigRecordVo;
import com.love.marriage.defaultAmountConfigRecord.vo.ResultDefaultAmountConfigRecordVo;
import com.love.marriage.defaultAmountConfigRecord.vo.ResultDefaultAmountConfigRecordVoPage;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * description:  默认金额配置操作记录表restApi
 * author:       system
 * createDate:   2024-12-07
 * version:      1.0.0
 */
@ApiSort(106)
@Tag(name = "默认金额配置操作记录表相关接口", description = "默认金额配置操作记录表相关接口")
@RestController
@RequiredArgsConstructor
@RequestMapping("/default-amount-config-record")
public class DefaultAmountConfigRecordController {

    private final DefaultAmountConfigRecordService defaultAmountConfigRecordService;

    @ApiOperationSupport(order = 10, author = "system")
    @Operation(summary = "获取默认金额配置操作记录分页", description = "获取默认金额配置操作记录分页")
    @ApiResponse(responseCode = "200", description = "Success",
            content = @Content(mediaType = "application/json",
                    schema = @Schema(implementation = ResultDefaultAmountConfigRecordVoPage.class
                    )))
    @PostMapping(value = "/page")
    @Parameters({
        @Parameter(name = "pageNum", description = "页码", required = false),
        @Parameter(name = "pageSize", description = "每页大小", required = false)
    })
    public Result<Page<DefaultAmountConfigRecordVo>> getPage(@RequestParam(value = "pageNum", required = false) Long pageNum,
                                             @RequestParam(value = "pageSize", required = false) Long pageSize,
                                             @RequestBody(required = false) DefaultAmountConfigRecordVo recordVo) {
        return Result.success(defaultAmountConfigRecordService.getPage(pageNum, pageSize, recordVo));
    }

    @ApiOperationSupport(order = 20, author = "system")
    @Operation(summary = "获取默认金额配置操作记录详情", description = "获取默认金额配置操作记录详情")
    @ApiResponse(responseCode = "200", description = "Success",
            content = @Content(mediaType = "application/json",
                    schema = @Schema(implementation = ResultDefaultAmountConfigRecordVo.class
                    )))
    @Parameters({
        @Parameter(name = "id", description = "id", required = true, schema = @Schema(implementation = Long.class, type = "Long", example = "1"))
    })
    @GetMapping
    public Result<DefaultAmountConfigRecordVo> query(@RequestParam(value = "id") Long id) {
        return Result.success(defaultAmountConfigRecordService.queryDefaultAmountConfigRecord(id));
    }

    @ApiOperationSupport(order = 30, author = "system")
    @Operation(summary = "根据配置ID获取操作记录分页", description = "根据配置ID获取操作记录分页")
    @ApiResponse(responseCode = "200", description = "Success",
            content = @Content(mediaType = "application/json",
                    schema = @Schema(implementation = ResultDefaultAmountConfigRecordVoPage.class
                    )))
    @Parameters({
        @Parameter(name = "configId", description = "配置ID", required = true, schema = @Schema(implementation = Long.class, type = "Long", example = "1")),
        @Parameter(name = "pageNum", description = "页码", required = false),
        @Parameter(name = "pageSize", description = "每页大小", required = false)
    })
    @GetMapping(value = "/config/{configId}")
    public Result<Page<DefaultAmountConfigRecordVo>> getPageByConfigId(@PathVariable("configId") Long configId,
                                                      @RequestParam(value = "pageNum", required = false) Long pageNum,
                                                      @RequestParam(value = "pageSize", required = false) Long pageSize) {
        return Result.success(defaultAmountConfigRecordService.getPageByConfigId(configId, pageNum, pageSize));
    }
}